package cn.book.action;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;

public class UploadAction extends BaseAction{
	private File picture;
	private String pictureContentType;
	private String pictureFileName;
	private String savePath;
	public File getPicture() {
		return picture;
	}
	public void setPicture(File picture) {
		this.picture = picture;
	}
	public String getPictureContentType() {
		return pictureContentType;
	}
	public void setPictureContentType(String pictureContentType) {
		this.pictureContentType = pictureContentType;
	}
	public String getPictureFileName() {
		return pictureFileName;
	}
	public void setPictureFileName(String pictureFileName) {
		this.pictureFileName = pictureFileName;
	}
	public String getSavePath() {
		return savePath;
	}
	public void setSavePath(String savePath) {
		this.savePath = savePath;
	}
	public String execute() throws IOException{
		getMapSession().put("fileName",pictureFileName);
		getMapSession().put("fileType",pictureContentType);
		String path=ServletActionContext.getServletContext().getRealPath("/bookpicture");
		File destFist=new File(path,pictureFileName);
		FileUtils.copyFile(picture, destFist);
		return SUCCESS;
	}

}
